<!DOCTYPE html>
<uieip type="page" value="login" debug="true" timeout="5000"></uieip>
<uieip type="reg" value="console,model"></uieip>
<html>

<head>
    <uieip type="file" value="inc" src="/yqwin/easyui/include.txt" cache="true" minute="1440"></uieip>
    <uieip type="file" value="css" src="/yqwin/css/yqwin.min" cache="true"></uieip>
    <uieip type="file" value="js" src="/yqwin/src/yqwin.min" cache="true"></uieip>
    <uieip type="tmpl" value="model.title"></uieip>
</head>

<body style="margin:0;overflow:hidden;">
    <table id="tb_ui">
    </table>
    <script>
        <uieip type="tmpl" value="model.params"></uieip>

        function form_load() {
            $(window).resize(function () {
                onresize();
            });
            onresize();

            if (_tb.uitype == "datagrid") { //表
                $("#tb_ui").yqDataGrid("loadData");
            } else if (_tb.uitype == "tree") { //结构树
                $("#tb_ui").yqTree("loadData");
            } else if (_tb.uitype == "combogrid") { //下拉列表
                $("#tb_ui").yqComboGrid("loadData");
            }
        }

        function onresize() {
            // var w = $(window).width();
            // var h = $(window).height();
            var w = window.innerWidth;
            var h = window.innerHeight;
            console.log("w:", w, "h:", h);
            if (_tb.uitype == "datagrid") { //表
                $("#tb_ui").yqDataGrid('resize', {
                    width: w,
                    height: h
                });
            } else if (_tb.uitype == "tree") { //结构树
                $("#tb_ui").yqTree('resize', {
                    width: w,
                    height: h
                });
            } else if (_tb.uitype == "combogrid") { //下拉列表
                // $("#tb_ui").yqDataGrid('resize', {
                // width: $(window).width(),
                // height: $(window).height()
                //});
            }
        }

        $(function () {
            init_ui();
        });

        function init_ui() {
            var opt = $.extend(_tb, {
                loadData: false,
                linkField: ["title"],
                afterBindingTitle: function () {
                    form_load();
                },
                onBeforeShowEdit: function (titles, action, row, callback) {      //add/upp/move 编辑执行前
                    console.log("onBeforeShowEdit", action, row);
                    if (action == "add") {
                        row["time"] = new Date();
                    }
                    callback(true, titles, row);      //true 执行编辑
                },
            });

            if (_tb.uitype == "datagrid") { //表
                $("#tb_ui").yqDataGrid(opt);
            } else if (_tb.uitype == "tree") { //结构树
                $("#tb_ui").yqTree(opt);
            } else if (_tb.uitype == "combogrid") { //下拉列表
                $("#tb_ui").yqComboGrid(opt);
            }
        }
    </script>
</body>

</html>